<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UserAccountEditForm
 *
 * @author Cesar
 */
class UserAccountEditForm extends UserForm{

  public function configure()
  {
    parent::configure();

    unset($this['validate']);

    $this->setWidget("email", new sfWidgetFormInputText());


    $this->widgetSchema->setLabels(array(
      'email' => 'Correo',
    ));

    $this->widgetSchema->setFormFormatterName('list');
    
    
    $this->setValidator('email', new sfValidatorAnd(array(
      new sfValidatorEmail(array('required' => true, 'trim' => true)),
      new sfValidatorString(array('required' => true, 'max_length' => 80)),
      new sfValidatorDoctrineUnique(array(
        'model' =>  'sfGuardUser',
        'column' => 'email_address'
      ), array('invalid' => 'An account with that email address already exists. If you have forgotten your password, click "cancel", then "Reset My Password."'))
    )));
       

  }
    
 
  public function doSave($con = null)
  {
    $user = $this->getObject()->getSfGuardUser();
    $user->setEmailAddress($this->getValue('email'));
    $user->save();
  
    return parent::doSave($con);
  }
  
}

?>
